package com.atguigu.springcloud.condition;

import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * 模拟springboot获取Tomcat的bean， 如果不存在依赖包则尝试其他
 * @author XiongJianLin
 * @date Created in 2025/2/12 10:33
 */
@Configuration
public class TomcatServer implements WebServer {

    @Bean
    // 传递条件类。 如果是true则生成bean
    @Conditional(TomcatCondition.class)
    public TomcatServer tomcat() {
        return new TomcatServer();
    }

    @Override
    public void start() throws WebServerException {

    }

    @Override
    public void stop() throws WebServerException {

    }

    @Override
    public int getPort() {
        return 0;
    }
}
